<template>
	<view class="certificate">
		<!-- <uni-card title="营业执照" :is-shadow="false" :border="false" :margin="'20rpx'" :spacing="'20rpx 40rpx'" :padding="0">
		    <view class="img">
				<view v-if="!hotState || hotState == 3 || hotState == 1" style="display: inline-block;" @click="upImag(1)">
					<view v-if="valiFormData.business_license" class="picker-img1">
						<image mode="widthFix" :src="licenseImg" style="width: 100%;" ></image>
					</view>
					<view v-else class="picker-img">
						
						<image class="main-img" mode="aspectFit" :src="imgUrl2" ></image>
						<text class="main-text">添加图片</text>
					</view>
				</view>
				<view v-else style="display: inline-block;">
					<view class="picker-img1">
						<image mode="aspectFill" :src="valiFormData.business_license[0]" style="width: 600rpx;height: 400rpx;" @click="lookImg(valiFormData.business_license[0])"></image>
					</view>
				</view>
			</view>
		</uni-card> -->
		<uni-card title="门店信息" :is-shadow="false" :border="false" :margin="'20rpx'" :spacing="'20rpx 40rpx'" :padding="0">
			<view class="input" >
			<uni-forms ref="valiForm" :recruits="rules" :modelValue="valiFormData" label-width="90">
				<!-- <uni-forms-item label="企业类型" required name="type">
					<picker v-if="!hotState || hotState == 3" @change="bindPickerChange" :value="value" :range="candidates">
						<view class="uni-input" :class="!value?'uni-input1':''">
						{{value?candidates[value]:'请选择企业类型'}}
						<uni-icons type="right" color="rgba(0,0,0,0.5)" size="22r"></uni-icons>
						</view>
					</picker>
					<view v-else class="text-box">
						{{candidates[valiFormData.type-1]}}
					</view>
					<uni-easyinput :clearable="false" :inputBorder="false" v-model="valiFormData.type" placeholder="请选择企业类型" trim="both" style="display: none;flex: 1;"/>
				</uni-forms-item> -->
				<!-- <uni-forms-item class="hideshow" label="信用代码"  name="license_num">
					<uni-easyinput :clearable="false" style="flex: 1;" v-if="!hotState || hotState == 3 || hotState == 1" :inputBorder="false" v-model="valiFormData.license_num" placeholder="请输入统一社会信用代码" trim="both" />
					<view v-else class="text-box">
						{{valiFormData.license_num}}
					</view>
				</uni-forms-item>
				<uni-forms-item class="hideshow" label="企业名称"  name="business_name">
					<uni-easyinput :clearable="false" style="flex: 1;" v-if="!hotState || hotState == 3 || hotState == 1" :inputBorder="false" v-model="valiFormData.business_name" placeholder="请输入企业名称" trim="both" />
					<view v-else class="text-box">
						{{valiFormData.business_name}}
					</view>
					
				</uni-forms-item>
				<uni-forms-item class="hideshow" label="法定代表人"  name="contacts">
					<uni-easyinput :clearable="false" style="flex: 1;" v-if="!hotState || hotState == 3 || hotState == 1" :inputBorder="false" v-model="valiFormData.contacts" placeholder="请输入联系人姓名" trim="both" />
					<view v-else class="text-box">
						{{valiFormData.contacts}}
					</view>
				</uni-forms-item> -->
				<uni-forms-item v-if="!hotState || hotState == 3  || hotState == 1" label="门店地址" required name="seat">
					<view class="input-address" :color="!valiFormData.address || !valiFormData.store_latitude?'':'input-address1'" @click="getAddress">
						{{!valiFormData.address || !valiFormData.store_latitude?'点击获取位置':'已获取位置'}}
						<uni-icons type="location-filled" :color="!valiFormData.address || !valiFormData.store_latitude?'#999999':'#D8EEFC'" :size="'40r'" />
					</view>
					<uni-easyinput :clearable="false" :inputBorder="false" v-model="valiFormData.seat" placeholder="请选择门店位置" trim="both" style="display: none;"/>
				</uni-forms-item>
				<uni-forms-item label="门店名称" required name="hotel_name">
					<uni-easyinput :clearable="false" style="flex: 1;" :inputBorder="false" v-model="valiFormData.hotel_name" placeholder="请输入门店名称" trim="both" />
				</uni-forms-item>
				<!-- <uni-forms-item label="联系人" required name="liaison">
					<uni-easyinput :clearable="false" style="flex: 1;" v-if="!hotState || hotState == 3 || hotState == 1" :inputBorder="false" v-model="valiFormData.liaison" placeholder="请输入联系人" trim="both" />
					<view v-else class="text-box">
						{{valiFormData.liaison ? valiFormData.liaison : ''}}
					</view>
				</uni-forms-item>
				<uni-forms-item label="联系电话" required name="telephone">
					<uni-easyinput :clearable="false" style="flex: 1;" v-if="!hotState || hotState == 3 || hotState == 1" :inputBorder="false" v-model="valiFormData.telephone" placeholder="请输入联系电话" trim="both" />
					<view v-else class="text-box">
						{{valiFormData.telephone ? valiFormData.telephone : ''}}
					</view>
				</uni-forms-item> -->
				<!-- <uni-forms-item label="详细地址" required name="address">
					<uni-easyinput :clearable="false" style="flex: 1;" v-if="!hotState || hotState == 3 || hotState == 1" :inputBorder="false" v-model="valiFormData.address" placeholder="请输入详细地址" trim="both" />
					<view v-else class="text-box">
						{{valiFormData.address}}
					</view>
				</uni-forms-item> -->
				<uni-forms-item label="职位" required name="address" >
					<view style="display: flex;justify-content: space-between;width: 100%;">
						<view style="flex: 1;text-align: right;padding-right: 20rpx;" v-if="!jobs" @tap="isZhi = true">选择职位</view>
						<view style="flex: 1;padding-right: 20rpx;" v-else @tap="isZhi = true">{{jobs}}</view>
						<uni-icons type="compose" @tap="addZhi" color="#D8EEFC" :size="'40r'" />
					</view>
				</uni-forms-item>
				<!-- <uni-forms-item label="详细地址" required name="detail_address" style="display: none;">
					<uni-easyinput :clearable="false" :inputBorder="false" v-model="valiFormData.detail_address" placeholder="详细地址" trim="both" />
				</uni-forms-item>
				<uni-forms-item label="经度" required name="store_longitude" style="display: none;">
					<uni-easyinput :clearable="false" :inputBorder="false" v-model="valiFormData.store_longitude" placeholder="请输入经度" trim="both" />
				</uni-forms-item>
				<uni-forms-item label="维度" required name="store_latitude" style="display: none;">
					<uni-easyinput :clearable="false" :inputBorder="false" v-model="valiFormData.store_latitude" placeholder="请输入维度" trim="both" />
				</uni-forms-item>
				<uni-forms-item label="酒店logo" required name="logo" style="display: none;">
					<uni-easyinput :clearable="false" :inputBorder="false" v-model="valiFormData.logo" placeholder="请输入酒店logo" trim="both" />
				</uni-forms-item>
				<uni-forms-item label="门店照片" required name="store_photos" style="display: none;">
					<uni-easyinput :clearable="false" :inputBorder="false" v-model="valiFormData.store_photos" placeholder="请输入门店照片" trim="both" />
				</uni-forms-item>
				<uni-forms-item label="营业执照" required name="business_license" style="display: none;">
					<uni-easyinput :clearable="false" :inputBorder="false" v-model="valiFormData.business_license" placeholder="请输入营业执照" trim="both" />
				</uni-forms-item> -->
			</uni-forms>
			</view> 
		</uni-card>
		<uni-card title="门头照片" :is-shadow="false" :border="false" :margin="'20rpx'" :spacing="'20rpx 40rpx'" :padding="0">
		    <view class="img1">
				<view v-if="status == 0" style="display: inline-block;" @click="upImag(2)">
					<view v-if="valiFormData.store_photos" class="img-box1">
						<image mode="scaleToFill" :src="fileImg" style="width: 100%;height: 100%;" ></image>
					</view>
					<view v-else class="img-box">
						<image class="main-img1" mode="aspectFit" :src="imgUrl" ></image>
						<text class="main-text">添加图片</text>
					</view>
				</view>
				<view v-else style="display: inline-block;" @click="upImag(1)">
					<view class="img-box1">
						<image mode="scaleToFill" :src="valiFormData.store_photos" style="width: 100%;height: 100%;" ></image>
					</view>
				</view>
			</view>
		</uni-card>
		<view class="zhi-box" v-show="isZhi">
			<view style="flex: 1;" @tap="isZhi = false"></view>
			<view class="zhi-small">
				<checkbox-group @change="checkboxChange" style="display: flex;flex-wrap: wrap;">
					<label class="uni-list-cell uni-list-cell-pd zhi-item" v-for="item in positionList" :key="item.id">
						<view>
							<checkbox :value="item.id" :checked="item.checked" />
						</view>
						<view>{{item.name}}</view>
					</label>
				</checkbox-group>
			</view>
		</view>
		<view class="place-btn" v-if="status== 0"  @tap="addMen">提交信息</view>
		<view class="place-btn" v-if="status== 3"  @tap="editMen">修改</view>
		<view class="place-btn" v-if="status== 1" >审核中</view>

<!-- 		<uni-card title="酒店logo" :is-shadow="false" :border="false" :margin="'20rpx'" :spacing="'20rpx 40rpx'" :padding="0">
		    <view class="img1">
				<view v-if="!hotState || hotState == 3" style="display: inline-block;" @click="upImag(3)">
					<view v-if="valiFormData.logo" class="img-box1">
						<image mode="scaleToFill" :src="logoImg" style="width: 100%;height: 100%;" ></image>
					</view>
					<view v-else class="img-box">
						<image class="main-img1" mode="aspectFit" :src="imgUrl" ></image>
						<text class="main-text">添加图片</text>
					</view>
				</view>
				<view v-else style="display: inline-block;">
					<view class="img-box1">
						<image mode="scaleToFill" :src="valiFormData.logo[0]" style="width: 100%;height: 100%;" ></image>
					</view>
				</view>
			</view>
		</uni-card> -->
		<!-- <view  class="certificate-but" v-if="hotState != 1">
			<template v-if="hotState == 2">
			<button v-if="status == 1" class="but but1" plain @click="transfer()">转让身份</button>
			<button v-else-if="status == 2" class="but but1" plain @click="Unbind()">解绑</button>
			</template>
			<button v-else-if="!hotState || hotState == 3" class="but" plain @click="submit('valiForm')">提交</button>
		
		</view>
		<view  class="certificate-but" v-if="hotState == 1">
			<button v-if="hotState == 1" class="but" plain @click="submit('valiForm')">修改</button>
		</view>
		<uni-popup ref="popup" type="bottom">
			<view class="get-tel">
				<view class="tel-title">
					提示
				</view>
				<view class="tel-text">解绑酒店后，部分功能将无法使用，需要绑定新的酒店才可继续使用！是否解绑酒店？</view>
				<view class="but">
					<button class="butt butt1" plain @click="close">否</button>
					<button class="butt" plain @click="okClick">是</button>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="popup1" type="bottom">
			<view class="get-tel">
				<view class="tel-title">
					转让管理员身份
				</view>
				<view class="tel-input">
					<uni-forms ref="phoneForm" :recruits="rules1" :modelValue="formData">
						<uni-forms-item label="手机号码" required name="phone" labelWidth="80">
							<uni-easyinput :clearable="false" :focus="true" type="number" v-model="formData.phone" placeholder="请输入被转让者手机号码" trim="both" />
						</uni-forms-item>
					</uni-forms>
				</view>
				<view class="but">
					<button class="butt butt2" plain @click="close">取消</button>
					<button class="butt" plain @click="okClick1('phoneForm')">确定</button>
				</view>
			</view>
		</uni-popup> -->
		<view class="prop" v-if="isAdd">
			<view style="flex: 1;" @tap="isAdd=false"></view>
			<view class="prop-box">
				<view class="prop-btn">
					<view class="" @tap="isAdd = false">取消</view>
					<view style="color: #D8EEFC;" @tap="affirm">确认</view>
				</view>
				<view class="prop-input">
					<input type="text" v-model="position_name" placeholder="请输入职位">
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				timer:'',
				position_name: '',
				imgUrl:`${getApp().globalData.imgScr}jd/xiangji.png`,
				imgUrl2:`${getApp().globalData.imgSc0r}jd/yingyezhizhao.png`,
				status: 0, // 酒店认证状态
				is_hotel_admin:0,//身份状态
				hotState: 0, // 酒店认证状态
				value:'', // 企业类型选择
				candidates: ['企业', '个体工商户'], // 企业类型选择数据
				isZhi: false,
				// 校验表单数据
				valiFormData: {
					// type: null, // 酒店类型1企业,2个体工商户
					hotel_name:'', // 酒店名称  
					// business_name:'', // 企业名称
					address: '', // 地址名称
					detail_address:'', // 详细地址
					// contacts:'', // 法定代表人 
					// telephone:'',//联系电话
					// liaison:'',//联系人
					// license_num: '', // 统一社会信用代码  
					// business_license:'', // 营业执照 
					store_photos: '', // 门店照片
					store_longitude:'', // 门店经度
					store_latitude: '', // 门店纬度
					position_ids: ''
				},
				// 校验规则
				rules: {
					// type: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '酒店类型不能为空'
					// 	},
					// 	{
					// 		format:'number',
					// 		errorMessage: '酒店类型不正确'
					// 	}]
					// },
					hotel_name: {
						recruits: [{
							required: true,
							errorMessage: '酒店名称不能为空'
						},
						{
							format:'string',
							errorMessage: '酒店名称不正确'
						}]
					},
					// logo: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '酒店logo不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '酒店logo不正确'
					// 	}]
					// },
					// business_name: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '企业名称不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '企业名称不正确'
					// 	}]
					// },
					address: {
						recruits: [{
							required: true,
							errorMessage: '详细地址不能为空'
						},
						{
							format:'string',
							errorMessage: '地址格式不正确'
						}]
					},
					detail_address: {
						recruits: [{
							required: true,
							errorMessage: '详细地址不能为空'
						},
						{
							format:'string',
							errorMessage: '地址格式不正确'
						}]
					},
					// contacts: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '法定代表人不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '法定代表人格式不正确'
					// 	}]
					// },
					// liaison: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '联系人不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '联系人格式不正确'
					// 	}]
					// },
					// telephone: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '联系电话不能为空'
					// 	},
					// 	{
					// 		pattern: '^[1]([3-9])[0-9]{9}$',
					// 		errorMessage: '联系电话不合法！'
					// 	},
					// 	{
					// 		format:'number',
					// 		errorMessage: '联系电话格式不正确'
					// 	}],
					// },
					// license_num: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '统一社会信用代码不能为空'
					// 	}]
					// },
					// business_license: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '营业执照不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '营业执照格式不正确'
					// 	}]
					// },
					// store_photos: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '门店照片不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '门店照片格式不正确'
					// 	}]
					// },
					// store_longitude: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '门店经度不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '门店经度格式不正确'
					// 	}]
					// },
					// store_latitude: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '门店纬度不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '门店纬度格式不正确'
					// 	}]
					// },
					// seat: {
					// 	recruits: [{
					// 		required: true,
					// 		errorMessage: '门店位置不能为空'
					// 	},
					// 	{
					// 		format:'string',
					// 		errorMessage: '门店位置格式不正确'
					// 	}]
					// },
				},
				licenseImg:'', // 营业执照上传 回显的数据
				fileImg:'', // 门店上传 回显的数据
				logoImg:'', // logo上传 回显的数据
				formData:{
					phone:'',
				},
				positionList: [],
				jobs: '',
				hotel_id: '',
				// 校验规则
				rules1: {
					phone: {
						recruits: [{
							required: true,
							errorMessage: '手机号码不能为空'
						},
						{
							pattern: '^[1]([3-9])[0-9]{9}$',
							errorMessage: '手机号不合法！'
						},
						{
							format:'number',
							errorMessage: '手机号格式不正确'
						}],
					}
				},
				isAdd: false
			}
		},
		async onLoad(options) {
			this.getposition()
			if(options.id){
				this.hotel_id = options.id
				this.getInfo()
			}
			try{
				// if(this.hotState) {
					// let rep = await this.$http.post('/index/Hotelpersonal/hotelinfo')
					console.log('认证信息=====>123',rep);
					this.hotState = rep.status || 0
					this.status = rep.is_hotel_admin || 0
					Object.assign(this.valiFormData,rep);
					if(this.hotState == 1){
						 this.licenseImg = rep.business_license[0]
						 this.valiFormData.seat = rep.address
						 this.valiFormData.store_photos = rep.store_photos[0]
						 this.valiFormData.business_license = rep.business_license[0]
					}
				// }else {
					if(!this.hotState || this.hotState == 3) Object.assign(this.$data, this.$options.data())
					// Object.assign(this.$data, this.$options.data())
				// }
			}catch(e){
				Object.assign(this.$data, this.$options.data())
				this.hotState = 0
				this.status = 0
				uni.showToast({
					title: e.errMsg,
					icon:"none"
				})
			}
		},
		methods: {
			bindPickerChange(e) {
				this.value = e.detail.value
				this.valiFormData.type = e.detail.value * 1 + 1
			},
			addZhi(){
				this.isAdd = true
			},
			affirm(){
				if(this.position_name.length>8){
					uni.showToast({
						title: '职位名称长度不得大于八个字',
						icon:'none'
					})
					return
				}
				const params = {
					position_name: this.position_name
				}
				this.$http.post('/index/Hotelpersonal/add_position', params).then(res => {
					uni.showToast({
						title: '新增成功'
					})
					this.position_name = ''
					this.isAdd = false
					this.getposition()
				}).catch(res => {
					uni.showToast({
						title: res.errMsg,
						icon: "none"
					})
				})
			},
			checkboxChange(e){
				let array = []
				let arr = e.detail.value
				for (let i in this.positionList) {
					for (let j in arr) {
						if(arr[j]==this.positionList[i].id){
							array.push(this.positionList[i].name)
						}
					}
				}
				this.jobs = array.join("  ")
				this.valiFormData.position_ids = e.detail.value.toString()
			},
			getposition(){
				const params = {
					
				}
				this.$http.post('/index/Index/position_list', params).then(res => {
					this.positionList = res
				}).catch(res => {
					uni.showToast({
						title: res.errMsg,
						icon: "none"
					})
				})
			},
			getInfo(){
				let that = this
				const params = {
					hotel_id: this.hotel_id
				}
				this.$http.post('/index/Hotelpersonal/hotelinfo', params).then(res => {
					that.status = res.status
					that.is_hotel_admin = res.is_hotel_admin || 0
					that.valiFormData.hotel_name = res.hotel_name
					that.valiFormData.store_photos = res.store_photos[0]
					that.valiFormData.detail_address = res.detail_address
					that.valiFormData.address = res.address
					that.valiFormData.store_latitude = res.store_latitude
					that.valiFormData.store_longitude = res.store_longitude
					that.valiFormData.position_ids = res.position_ids
					that.valiFormData.hotel_id = res.id
					let array = []
					let arr = res.position_ids.split(",")
					for (let i in that.positionList) {
						for (let j in arr) {
							if(that.positionList[i].id==arr[j]){
								array.push(that.positionList[i].name)
								that.positionList[i].checked = true
							}
						}
					}
					that.jobs = array.join("  ")
				}).catch(res => {
					uni.showToast({
						title: res.errMsg,
						icon: "none"
					})
				})
			},
			addMen(){
				uni.showLoading({
				       title: '申请中...',
				       mask: true
				      })
				delete this.valiFormData.seat
				const params = this.valiFormData
				this.$http.post('/index/Hotelpersonal/authentication', params).then(res => {
					uni.hideLoading()
					uni.switchTab({
					    url: '/pages/tag/home/home'
					});
				}).catch(err => {
					uni.hideLoading()
					if(err.length > 0) {
						uni.showToast({
							title: err[0].errorMessage,
							icon:"none"
						})
					} else if(err.errMsg){
						uni.showToast({
							title: err.errMsg,
							icon:"none"
						})
					}
				})
			},
			async upImag(i) {
				let _this = this
				try{
					let res = await uni.chooseImage()
					if(res[0]) throw new Error(JSON.stringify(res[0]))
					 let tempFilePaths = res[1].tempFilePaths;
					 if(i == 1) this.licenseImg = tempFilePaths[0]
					 if(i == 2) this.fileImg = tempFilePaths[0]
					 if(i == 3) this.logoImg = tempFilePaths[0]
					 uni.showLoading({
					 	title: '图片上传中....',
						mask:true,
					 });
					 let rep = await uni.uploadFile({
				            // url: 'https://www.zhuoxianrenli.cn/index/hotelindex/uploadImage', //图片上传接口
				            url: `${getApp().globalData.url}index/hotelindex/uploadImage`, //图片上传接口
				            filePath: tempFilePaths[0],
				            name: 'file',
							header: {
							"Content-Type": "multipart/form-data",
							},
						})
					// 根据接口具体返回格式   赋值具体对应url 
										this.valiFormData.store_photos = `${getApp().globalData.url}uploads`+JSON.parse(rep[1].data).file
					if(i == 1) {
						this.valiFormData.business_license = JSON.parse(rep[1].data).file
						// let ImageUrl = 'https://www.zhuoxianrenli.cn/uploads/'+JSON.parse(rep[1].data).file
						let ImageUrl = `${getApp().globalData.url}uploads`+JSON.parse(rep[1].data).file
						let reo = await this.$http.post('/index/Communal/licenseocr',{ImageUrl})
						if(reo[0].Name == "统一社会信用代码") {
							this.valiFormData.license_num = reo[0].Value // 统一社会信用代码
							this.valiFormData.contacts = reo[1].Value // 法定代表人
							this.valiFormData.business_name = reo[2].Value // 企业名称
						}else {
							throw new Error(JSON.stringify({errMsg:'识别失败'}))
						}
					}else if(i == 2){
						this.valiFormData.store_photos = JSON.parse(rep[1].data).file
					}else {
						this.valiFormData.logo = JSON.parse(rep[1].data).file
					}
					uni.hideLoading()
				}catch(e){
					console.log('e =========>',e);
					uni.hideLoading()
					//TODO handle the exception
					if(e.message && JSON.parse(e.message)) {
						// 取消图片选择
					}else {
						uni.showToast({
							title:e.errMsg,
							icon:"none"
						})
					}
				}
			},
			/**
			 * 获取位置
			 */
			 getAddress() {
				 let _this = this
				 uni.authorize({
				    scope: 'scope.userLocation',
				    success() {
				        uni.chooseLocation({
				            success: function (res) {
								console.log(res)
								_this.valiFormData.store_longitude = res.longitude.toString() // 获取经度
								_this.valiFormData.store_latitude = res.latitude.toString() // 获取纬度
								_this.valiFormData.hotel_name = res.name // 获取名称
								_this.valiFormData.address = res.name == ''?res.address:res.name // 获取详细地址
								_this.valiFormData.detail_address = res.address // 获取详细地址
								_this.valiFormData.seat = res.name == ''?res.address:res.name // 获取详细地址
				            },
				        	fail(e) {
				        		// uni.showToast({
				        		// 	title: e.errMsg,
				        		// 	icon:"none"
				        		// })
				        	}
				        });
				    },
					fail(e){
						uni.showToast({
							title:"获取位置失败！",
							icon:"none"
						})
					}
				})
			},
			/**
			 * 提交按钮
			 */
			async submit(ref) {
				let _this = this
				uni.showLoading({
				       title: '申请中...',
				       mask: true
				      })
				try {
					let res = await this.$refs[ref].validate()
					delete res.seat
	
					let data = await this.$http.post('/index/Hotelpersonal/authentication',res)
					let obj = uni.getStorageSync('hotelData')
					obj.state = 1
					uni.setStorageSync('hotelData', obj);
					uni.hideLoading()
					uni.switchTab({
					    url: '/pages/tag/home/home'
					});
				}catch (err) {
					uni.hideLoading()
					if(err.length > 0) {
						uni.showToast({
							title: err[0].errorMessage,
							icon:"none"
						})
					} else if(err.errMsg){
						uni.showToast({
							title: err.errMsg,
							icon:"none"
						})
					}
				}
			},
			/**
			 * 转让身份事件
			 */
			transfer() {
				this.$refs.popup1.open('center')
			},
			/**
			 * 确定按钮
			 */
			async okClick1 (ref) {
				let _this = this
				try {
					let res = await this.$refs[ref].validate()
					let req = await this.$http.post('/index/Hotelpersonal/assignment_admin',res)
					// 返回到列表页
					this.$refs.popup1.close()
					uni.showToast({
						title: '转让成功！',
						icon:"none"
					})
					this.timer = setTimeout(() => {
					    uni.navigateBack({
					    	delta: 1
					    });
						clearTimeout(_this.timer)
					}, 1000);
				}catch (err) {
					if(err.length > 0) {
						uni.showToast({
							title: err[0].errorMessage,
							icon:"none"
						})
					} else if (err.statusCode == 1002 || err.statusCode == 1003) {
						uni.showToast({
							title: err.errMsg,
							icon:"none"
						})
					}
				}
				
				
				
			},
			/**
			 * 解绑事件
			 */
			Unbind() {
				this.$refs.popup.open('center')
			},
			/**
			 * 否 关闭弹窗
			 */
			close() {
				this.$refs.popup.close()
				this.$refs.popup1.close()
				this.phone = ''
			},
			/**
			 * 是 确定解绑
			 */
			async okClick() {
				try{
					let res = await this.$http.post('/index/Hotelpersonal/unbind_admin')
					this.$refs.popup.close()
					uni.showToast({
						title: res.msg,
						icon:"none"
					})
					this.timer = setTimeout(() => {
					    uni.navigateBack({
					    	delta: 1
					    });
						clearTimeout(this.timer)
					}, 1000);
				}catch(err){
					uni.showToast({
						title: err.errMsg,
						icon:"none"
					})
				}
			},
			/**
			 * 预览头像
			 */
			lookImg(url) {
				uni.previewImage({
					urls:[url]
				})
			},
			editMen(){
				uni.showLoading({
				       title: '修改中...',
				       mask: true
				      })
				delete this.valiFormData.seat
				const params = this.valiFormData
				params.id = this.hotel_id
				this.$http.post('/index/Hotelpersonal/authentication', params).then(res => {
					uni.hideLoading()
					setTimeout(function(){
						uni.navigateBack(1)
					},1000)
				}).catch(err => {
					uni.hideLoading()
					if(err.length > 0) {
						uni.showToast({
							title: err[0].errorMessage,
							icon:"none"
						})
					} else if(err.errMsg){
						uni.showToast({
							title: err.errMsg,
							icon:"none"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.uni-card .uni-card__header .uni-card__header-content {
	  justify-content: flex-start!important;
	
	}
	.hideshow{
		display: none;
	}
.certificate {
	.uni-card {
		border-radius: 20rpx;
		.uni-card__header {
			border-bottom: 1rpx solid #EDEDED;
			.uni-ellipsis {
				font-size: 28rpx;
				font-weight: bold;
				color: #000000;
			}
		}
	}
	
	.img {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		padding: 20rpx;
		box-sizing: border-box;
		.picker-img1 {
			width: 600rpx;
			height: 100%;
		}
		.picker-img {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			width: 476rpx;
			height: 324rpx;
			border-radius: 20rpx;
			background-color: #F5F7FD;
			// padding-top: 20rpx;
			overflow: hidden;
			.main-img {
				width: 300rpx;
				height: 206rpx;
				margin-top: 20rpx;
			}
			.main-text {
				width: 100%;
				height: 68rpx;
				line-height: 68rpx;
				text-align: center;
				font-size: 28rpx;
				font-weight: 500;
				color: #FFFFFF;
				background: linear-gradient(-90deg, #8dc9f1, #d8eefc);
			}
		}
	}
	.input {
		.text-box {
			font-size: 28rpx;
			font-weight: 500;
			color: #000000;
		}
		.label-text {
			font-size: 28rpx;
			font-weight: 500;
		}
		.uni-forms-item__inner {
			// padding: 0;
			.uni-forms-item__content {
				display: flex;
				flex-direction: row-reverse;
				align-items: center;
			}
		}
		.uni-input {
			line-height: 36px;
			font-size: 28rpx;
			font-weight: 500;
			color: #000000;
		}
		.uni-input1 {
			font-weight: 400;
			color: rgba($color: #000000, $alpha: 0.7);
		}
		.uni-easyinput__content-input, .uni-combox__input {
			text-align: right;
		}
		.uni-easyinput__placeholder-class {
			font-size: 28rpx;
			font-weight: 400;
			color: rgba($color: #000000, $alpha: 0.7);
		}
		.input-address {
			font-size: 28rpx;
			font-weight: 400;
			color: rgba($color: #000000, $alpha: 0.7);
			
		}
		.input-address1 {
			font-size: 28rpx;
			font-weight: 500;
			color: #000000;
		}
	}
	.img1 {
		width: 100%;
		margin-bottom: 20rpx;
		box-sizing: border-box;
		.img-box {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			background-color: #F5F7FD;
		}
		.img-box1 {
			width: 200rpx;
			height: 200rpx;
		}
		.main-img1 {
			width: 100rpx;
			height: 100rpx;
			margin-bottom: 10rpx;
		}
		.main-text {
			font-size: 24rpx;
			color: rgba($color: #000000, $alpha: 0.4);
		}
	}
	.certificate-but {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		height: 80rpx;
		margin-bottom: 40rpx;
		.but {
			flex: 1;
			background: linear-gradient(-90deg, #8dc9f1, #d8eefc);
			border-radius: 40rpx;
			line-height: 80rpx;
			font-size: 34rpx;
			font-weight: 600;
			color: #FFFFFF;
			border: 0;
			margin: 0 20rpx;
		}
		.but1 {
			background: linear-gradient(-90deg, #e43d33, #e43d33);
		}
	}
	.get-tel {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		width: 508rpx;
		padding: 40rpx;
		border-radius: 20rpx;
		overflow: hidden;
		background-color: #FFFFFF;
		.tel-title {
			font-size: 34rpx;
			font-size: #000000;
			font-weight: 500;
			margin-bottom: 40rpx;
		}
		.tel-text {
			font-size: 28rpx;
			font-size: #737373;
			font-weight: 500;
			text-align: center;
			margin-bottom: 100rpx;
		}
		.tel-input {
			
		}
		.but {
			display: flex;
			justify-content: center;
			width: 100%;
			
			.butt {
				font-size: 28rpx;
				font-weight: 500;
				color: #FFFFFF;
				background: linear-gradient(-90deg, #8dc9f1, #d8eefc);
				border-radius: 34rpx;
				line-height: 68rpx;
				border: 0;
				padding: 0 60rpx;
			}
			.butt1 {
				background: linear-gradient(-90deg, #e43d33, #e43d33);
			}
			.butt2 {
				color: #000000;
				border: 2rpx solid #EDEDED;
				background: rgba(0, 0, 0, 0);
			}
		}
	}
}
.zhi-box{
	background-color: rgba(0,0,0,0.5);
	position: fixed;
	z-index: 9999;
	width: 100%;
	height: 100vh;
	top: 0;
	left: 0;
	display: flex;
	.zhi-small{
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		z-index: 9999999;
		height: 600rpx;
		background-color: #FFFFFF;
		border-radius: 13rpx 13rpx 0 0;
		padding: 30rpx;
		overflow: auto;
	}
	.zhi-item{
		width: 50%;
		display: flex;
		margin-bottom: 60rpx;
	}
}
.place-btn{
		width: 622rpx;
		height: 96rpx;
		text-align: center;
		line-height: 96rpx;
		color: #fff;
		background: linear-gradient(to right,#8dc9f1,#d8eefc);
		border-radius: 96rpx;
		margin: 0 auto;
		font-size: 36rpx;
		letter-spacing: 2rpx;
	}
	.prop{
		width: 100%;
		height: 100vh;
		background-color: rgba(0,0,0,0.5);
		display: flex;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 99;
		.prop-box{
			width: 100%;
			height: 300rpx;
			position: absolute;
			left: 0;
			bottom: 0;
			background-color: #fff;
			border-radius: 30rpx 30rpx 0 0;
			overflow: hidden;
			padding: 30rpx;
			.prop-btn{
				display: flex;
				font-size: 28rpx;
				color: #757575;
				justify-content: space-between;
				view{
					width: 100rpx;
					text-align: center;
				}
			}
			.prop-input{
				width: 100%;
				height: 100rpx;
				margin-top: 40rpx;
				input{
					width: 100%;
					height: 100rpx;
				}
			}
		}
	}
	.addBtn{
		width: 132rpx;
		height: 64rpx;
		text-align: center;
		line-height: 64rpx;
		font-size: 26rpx;
		color: #fff;
		border-radius: 6rpx;
		background-color: #D8EEFC;
	}
</style>
